package org.blim.blackdawn.resource;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import android.content.Context;

public class ResourceUtils {
	
	public static String readRawResource(
			final Context context,
			final int resourceId) throws IOException {
		
		final InputStream inputStream = 
				context.getResources().openRawResource(resourceId);
		final InputStreamReader inputStreamReader = 
				new InputStreamReader(inputStream);
		final BufferedReader reader = 
				new BufferedReader(inputStreamReader);

		String line;
		final StringBuilder resource = new StringBuilder();

		while ((line = reader.readLine()) != null) {
			resource.append(line).append('\n');
		}

		return resource.toString();
	}
}
